$(function(){
	var nindex = 1;//当前加的序列
	var page = 1;
	loadPage();
	function loadPage(){
		$.ajax({
			url : ctx + "/web/jnyz/productGrid",
			type : "post",
			data : {
				page : page,
				rows : 12,
				type : $("#stype").val()
			},
			success : function(data){
				$("#totalPage").val(data.totalPage);
				var rows = data.rows;
				for(var i = 0; i < rows.length; i++){
					var shtml = $("<li>"+
									"<dl>"+
									"<dt><a href='"+ctx+"/web/jnyz/productDetail/"+rows[i].id+"'><img src='"+ctx+"/uploadfile/image/"+rows[i].firstjjtp+"' alt=''></a></dt>"+
									"<dd><a href='"+ctx+"/web/jnyz/productDetail/"+rows[i].id+"' class='t'>"+rows[i].title+"</a></dd>"+
									"</dl>"+
								"</li>");
					$("#showlist"+nindex).append(shtml);
					nindex++;
					if(nindex == 5){
						nindex = 1;
					}
				}
				
				if(data.totalPage>page){
					$("#loaddata").show();
				}else{
					$("#loaddata").hide();
				}
				page = page + 1;
			}
		});
	}
	
	$("#loadMore").click(function(){
		loadPage();
	});
});